/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package slcu.model;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.model.BaseModel;
import com.liferay.portal.model.impl.BaseModelImpl;

import slcu.service.CategoriaDisciplinaLocalServiceUtil;

import java.io.Serializable;

import java.lang.reflect.Proxy;

import java.util.HashMap;
import java.util.Map;

/**
 * @author tito
 */
public class CategoriaDisciplinaClp extends BaseModelImpl<CategoriaDisciplina>
	implements CategoriaDisciplina {
	public CategoriaDisciplinaClp() {
	}

	public Class<?> getModelClass() {
		return CategoriaDisciplina.class;
	}

	public String getModelClassName() {
		return CategoriaDisciplina.class.getName();
	}

	public long getPrimaryKey() {
		return _categoriaId;
	}

	public void setPrimaryKey(long primaryKey) {
		setCategoriaId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_categoriaId);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	@Override
	public Map<String, Object> getModelAttributes() {
		Map<String, Object> attributes = new HashMap<String, Object>();

		attributes.put("categoriaId", getCategoriaId());
		attributes.put("disciplinaId", getDisciplinaId());
		attributes.put("nombre", getNombre());
		attributes.put("edadMinima", getEdadMinima());
		attributes.put("edadMaxima", getEdadMaxima());

		return attributes;
	}

	@Override
	public void setModelAttributes(Map<String, Object> attributes) {
		Long categoriaId = (Long)attributes.get("categoriaId");

		if (categoriaId != null) {
			setCategoriaId(categoriaId);
		}

		Long disciplinaId = (Long)attributes.get("disciplinaId");

		if (disciplinaId != null) {
			setDisciplinaId(disciplinaId);
		}

		String nombre = (String)attributes.get("nombre");

		if (nombre != null) {
			setNombre(nombre);
		}

		Long edadMinima = (Long)attributes.get("edadMinima");

		if (edadMinima != null) {
			setEdadMinima(edadMinima);
		}

		Long edadMaxima = (Long)attributes.get("edadMaxima");

		if (edadMaxima != null) {
			setEdadMaxima(edadMaxima);
		}
	}

	public long getCategoriaId() {
		return _categoriaId;
	}

	public void setCategoriaId(long categoriaId) {
		_categoriaId = categoriaId;
	}

	public long getDisciplinaId() {
		return _disciplinaId;
	}

	public void setDisciplinaId(long disciplinaId) {
		_disciplinaId = disciplinaId;
	}

	public String getNombre() {
		return _nombre;
	}

	public void setNombre(String nombre) {
		_nombre = nombre;
	}

	public long getEdadMinima() {
		return _edadMinima;
	}

	public void setEdadMinima(long edadMinima) {
		_edadMinima = edadMinima;
	}

	public long getEdadMaxima() {
		return _edadMaxima;
	}

	public void setEdadMaxima(long edadMaxima) {
		_edadMaxima = edadMaxima;
	}

	public slcu.model.Disciplina getDisciplina() {
		throw new UnsupportedOperationException();
	}

	public BaseModel<?> getCategoriaDisciplinaRemoteModel() {
		return _categoriaDisciplinaRemoteModel;
	}

	public void setCategoriaDisciplinaRemoteModel(
		BaseModel<?> categoriaDisciplinaRemoteModel) {
		_categoriaDisciplinaRemoteModel = categoriaDisciplinaRemoteModel;
	}

	public void persist() throws SystemException {
		if (this.isNew()) {
			CategoriaDisciplinaLocalServiceUtil.addCategoriaDisciplina(this);
		}
		else {
			CategoriaDisciplinaLocalServiceUtil.updateCategoriaDisciplina(this);
		}
	}

	@Override
	public CategoriaDisciplina toEscapedModel() {
		return (CategoriaDisciplina)Proxy.newProxyInstance(CategoriaDisciplina.class.getClassLoader(),
			new Class[] { CategoriaDisciplina.class },
			new AutoEscapeBeanHandler(this));
	}

	@Override
	public Object clone() {
		CategoriaDisciplinaClp clone = new CategoriaDisciplinaClp();

		clone.setCategoriaId(getCategoriaId());
		clone.setDisciplinaId(getDisciplinaId());
		clone.setNombre(getNombre());
		clone.setEdadMinima(getEdadMinima());
		clone.setEdadMaxima(getEdadMaxima());

		return clone;
	}

	public int compareTo(CategoriaDisciplina categoriaDisciplina) {
		int value = 0;

		value = getNombre().compareTo(categoriaDisciplina.getNombre());

		if (value != 0) {
			return value;
		}

		return 0;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		CategoriaDisciplinaClp categoriaDisciplina = null;

		try {
			categoriaDisciplina = (CategoriaDisciplinaClp)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = categoriaDisciplina.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(11);

		sb.append("{categoriaId=");
		sb.append(getCategoriaId());
		sb.append(", disciplinaId=");
		sb.append(getDisciplinaId());
		sb.append(", nombre=");
		sb.append(getNombre());
		sb.append(", edadMinima=");
		sb.append(getEdadMinima());
		sb.append(", edadMaxima=");
		sb.append(getEdadMaxima());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(19);

		sb.append("<model><model-name>");
		sb.append("slcu.model.CategoriaDisciplina");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>categoriaId</column-name><column-value><![CDATA[");
		sb.append(getCategoriaId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>disciplinaId</column-name><column-value><![CDATA[");
		sb.append(getDisciplinaId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>nombre</column-name><column-value><![CDATA[");
		sb.append(getNombre());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>edadMinima</column-name><column-value><![CDATA[");
		sb.append(getEdadMinima());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>edadMaxima</column-name><column-value><![CDATA[");
		sb.append(getEdadMaxima());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private long _categoriaId;
	private long _disciplinaId;
	private String _nombre;
	private long _edadMinima;
	private long _edadMaxima;
	private BaseModel<?> _categoriaDisciplinaRemoteModel;
}